"""
localStorage:永久有效
sessionStorage:窗口关闭，会话结束自动删除
cookie: 可以指定有效期，多用于储存用户信息 等
"""

import requests

# 模拟登录获取cookie
# url = "https://vip.hdbz.net/auth/ajaxlogin"
# data = {
#     "username": "17633974985",
#     "userpwd": "123456abc"
# }
# res = requests.post(url=url, data=data)
# if res.status_code == 200:
#     # RequestCookieJar
#     print(res.cookies)

    # #方法一 直接使用cookiejar
    # home_res = requests.get("https://vip.hdbz.net/site/FavoriteList?page=1&limit=10")
    # print(home_res.json())

    # #方法二 直接使用cookie字典
    # cookies = {
    #     "uid": res.cookies.get("uid"),
    #     "uname": res.cookies.get("uname"),
    #     "unotify": res.cookies.get("unotify")
    # }
    # home_res = requests.get("https://vip.hdbz.net/site/FavoriteList?page=1&limit=10", cookies=cookies)
    # print(home_res.json())

    # # 方法三 在headers中使用cookie
    # headers = {
    #     "cookie": f'uid={res.cookies.get("uid")};uname={res.cookies.get("uname")};unotify={res.cookies.get("unotify")}'
    # }
    # home_res = requests.get("https://vip.hdbz.net/site/FavoriteList?page=1&limit=10", headers=headers)
    # print(home_res.json())

# 如果不能轻松的模拟登录获取cookie， 则可以在浏览器登录之后 手动复制cookie
# 但是随着cookie过期则需要再次手动赋值
headers = {
	"cookie": f'isVip=0; userNickname=17633974985; userimg=	https%3A%2F%2Fvip.hdbz.net%2Favatar%2Fnoavatar.png; Hm_lvt_c555701034a208b65b9f7b81d7aa331f=1743492480,1743496122,1743501321; Hm_lpvt_c555701034a208b65b9f7b81d7aa331f=1743501321; HMACCOUNT=E88E6FFE8345712A; uname=17633974985; unotify=ae838e2686ef8861ba634b75ac1cf5d2; uid=18611'
}
# favorite_res = requests.get("https://vip.hdbz.net/site/FavoriteList?page=1&limit=10", headers=headers)
# print(favorite_res.json())


download_res = requests.get("https://vip.hdbz.net/site/downloadlist?page=1&limit=10", headers=headers)
print(download_res.json())




